﻿using DynamicViewFormApp.Setting;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DynamicViewFormApp
{
    public partial class NewForm : Form
    {
        public NewForm()
        {
            InitializeComponent();

            comboBox_paperSize.SelectedIndex = 0;
        }


        private void ButtonOK_Click(object sender, EventArgs e)
        {
            if (textBox_title.Text != "")
            {
                ExamInfo.ExamName = textBox_title.Text;
                PaperSetting.Type = comboBox_paperSize.SelectedItem.ToString();
                PublicVariable.IsCanNew = true;
                this.Close();
            }
            else
            {
                MessageBox.Show("请填写考试名称");
            }
        }

        private void NewForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            MainForm mainForm = (MainForm)this.Owner;//获取拥有此窗体的窗体
            mainForm.CloseStartForm();
            if (PublicVariable.IsCanNew)
            {
                mainForm.Text = textBox_title.Text;
                mainForm.InitData();
            }
        }

        private void NewForm_Load(object sender, EventArgs e)
        {
            PublicVariable.IsCanNew = false;
        }

        private void ButtonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
